package fisio.connection;

import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class ConnectionManager {
	
	private static final String DATASOURCE = "jdbc/fisio";
	
	public static Connection getConnection() {
		
		try {
			
			Context initialContext = new InitialContext();
			Context envContext = (Context)initialContext.lookup("java:/comp/env");
			DataSource dataSource = (DataSource)envContext.lookup(DATASOURCE);
			return dataSource.getConnection();
			
		} catch(Exception e) {
			System.out.println("\nERRO ao conectar datasource: "+e.getMessage());
			return null;
		}
	}
}